package cn.yinyu.queue.module.ecg.enums;

import cn.hutool.core.util.ObjUtil;
import cn.yinyu.queue.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 通用状态枚举
 *
 * @author 垠域源码
 */
@Getter
@AllArgsConstructor
public enum DevStateEnum implements IntArrayValuable {
    FREE(0, "空闲"),
    RECEIVED(5, "已领取"),
    INUSE(10, "使用中"),
    LOST(20, "已遗失"),
    DAMAGED(30, "已损坏"),
    UNDER_MAINTENANCE(40, "维修中"),
    SCRAPPED(50, "已报废");

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DevStateEnum::getState).toArray();

    /**
     * 状态值
     */
    private final Integer state;
    /**
     * 状态名
     */
    private final String name;

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public boolean isEqual(Integer state) {
        return ObjUtil.equal(this.state, state);
    }
}
